//
//  CJInterstitialGMAdapter.m
//  CJModileGMAdapter
//
//  Created by shanghailingye on 2024/4/24.
//

#import "CJInterstitialGMAdapter.h"

@interface CJInterstitialGMAdapter()<CJInterstitialAdDelegate>

@property (nonatomic, strong) CJInterstitialAd *interstitialAd;

@end
@implementation CJInterstitialGMAdapter

- (BUMMediatedAdStatus)mediatedAdStatus {
    return BUMMediatedAdStatusNormal;
}

- (void)loadInterstitialAdWithSlotID:(NSString *)slotID andSize:(CGSize)size parameter:(NSDictionary *)parameter {
    self.interstitialAd = [[CJInterstitialAd alloc] initWithResourceId:slotID];
    self.interstitialAd.delegate = self;
    [self.interstitialAd loadAdData];
}

- (BOOL)showAdFromRootViewController:(UIViewController *)viewController parameter:(NSDictionary *)parameter {
    [self.interstitialAd showFromRootViewController:viewController];
    return YES;
}

- (void)didReceiveBidResult:(BUMMediaBidResult *)result {
    // 在此处理Client Bidding的结果回调
}

#pragma mark CJInterstitialAdDelegate
- (void)interstitialAdDidLoad:(nonnull CJInterstitialAd *)interstitialAd resourceId:(nonnull NSString *)resourceId {
    [self.bridge interstitialAd:self didLoadWithExt:@{}];
}

- (void)interstitialAdLoadFailed:(nonnull CJInterstitialAd *)interstitialAd error:(nonnull NSError *)error {
    [self.bridge interstitialAd:self didLoadFailWithError:error ext:@{}];
}

- (void)interstitialAdOnClicked:(nonnull CJInterstitialAd *)interstitialAd {
    [self.bridge interstitialAdDidClick:self];
}

- (void)interstitialAdOnClosed:(nonnull CJInterstitialAd *)interstitialAd {
    [self.bridge interstitialAdDidClose:self];
}

- (void)interstitialAdOnShow:(nonnull CJInterstitialAd *)interstitialAd {
    [self.bridge interstitialAdDidVisible:self];
}



@end
